use crate::db::db_insert::db_insert;
use crate::db::db_select::db_select;

pub async fn set_volume(volume: u8) {
    let mut vol:u8 = 0;
    if(volume<0 || volume>100){
        eprintln!("Volume must be between 0 and 100, got: {volume}");
        vol = 100;
    }else{
        vol = volume;
    }
    db_insert("volume", vol.to_string().as_str()).await.unwrap();
}
pub async fn get_volume() -> u8 {
    let mut vol:u8 = 0;
    match db_select("volume").await {
        Ok(volume) => {
            vol = volume.value.parse().unwrap();
            return vol;
        },
        Err(_) => {
            vol = 100;
            return vol;
        }
    }
}